package com.starleague.battletech.game;

import java.util.List;
import java.util.Map;

import com.google.common.collect.Lists;

import com.starleague.battletech.hexagonal.AbstractBattletechHexGrid;
import com.starleague.battletech.unit.AbstractBattletechUnit;
import com.starleague.battletech.unit.IMutableBattletechUnit;
import com.starleague.game.AbstractGame;

public abstract class AbstractBattletechGame
        extends AbstractGame
        implements IMutableBattletechGame
{
    private List<? extends AbstractBattletechTeam> teams;
    private AbstractBattletechHexGrid hexGrid;
    private List<? extends AbstractBattletechUnit> units;
    private int turn;
    private BattletechPhase phase;
    private AbstractBattletechTeam currentTeam;
    private AbstractBattletechUnit currentUnit;

    protected AbstractBattletechGame(String name)
    {
        super(name);
        this.teams = Lists.newArrayList();
        this.units = Lists.newArrayList();
        this.phase = BattletechPhase.NONE;
    }

    protected AbstractBattletechGame()
    {
        //
    }

    @Override
    public AbstractBattletechHexGrid getHexGrid()
    {
        return this.hexGrid;
    }

    public void setHexGrid(AbstractBattletechHexGrid hexGrid)
    {
        this.hexGrid = hexGrid;
    }

    @Override
    public List<? extends AbstractBattletechTeam> getTeams()
    {
        return this.teams;
    }

    @Override
    public List<? extends AbstractBattletechUnit> getUnits()
    {
        return this.units;
    }

    @Override
    public int getTurn()
    {
        return this.turn;
    }

    @Override
    public void setTurn(int turn)
    {
        this.turn = turn;
    }

    @Override
    public BattletechPhase getPhase()
    {
        return this.phase;
    }

    @Override
    public void setPhase(BattletechPhase phase)
    {
        this.phase = phase;
    }

    @Override
    public AbstractBattletechTeam getCurrentTeam()
    {
        return this.currentTeam;
    }

    @Override
    public void setCurrentTeam(IMutableBattletechTeam currentTeam)
    {
        this.currentTeam = (AbstractBattletechTeam) currentTeam;
    }

    @Override
    public AbstractBattletechUnit getCurrentUnit()
    {
        return this.currentUnit;
    }

    @Override
    public void setCurrentUnit(IMutableBattletechUnit currentUnit)
    {
        this.currentUnit = (AbstractBattletechUnit) currentUnit;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("turn", this.turn);
        infoPropertyMap.put("phase", this.phase);
        infoPropertyMap.put("hexGrid", this.hexGrid);
        infoPropertyMap.put("teams", this.teams);
        infoPropertyMap.put("currentTeam", this.currentTeam);
        infoPropertyMap.put("units", this.units);
        infoPropertyMap.put("currentUnit", this.currentUnit);
        return infoPropertyMap;
    }
}
